home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright © 1994 Mikhail Fridberg. Part of this code is copyrighted by Steve Falkenburg
-
- Telnet-based talk server/client
-
- connection management is done through the use of Operating System queues to simplify tracking
- and usage.
- */
-
- #include <CommResources.h>
- #include <Terminals.h>
- #include <Connections.h>
-
- #include "const.h"
- #include "globals.h"
- #include "utils.h"
- #include "interface.h"
-
-
- /* initializes the user interface by loading our dialog into memory, and drawing the initial
- queue numbers into the dialog
- */
-
- void InitInterface(void)
- {
- gMainDialog = GetNewDialog(kMainDialog,nil,(WindowPtr)-1L);
- UpdateNumberList();
- }
-
-
- /* displays the current values for the number of parameter blocks in each of the queues
- (unused, running, completed)
- */
-
- void UpdateNumberList(void)
- {
- short iType;
- Handle iHndl;
- Rect iRect;
- Str255 iText;
- long lastValue;
-
- GetDItem(gMainDialog,kServicedItem,&iType,&iHndl,&iRect);
- GetIText(iHndl,iText);
- StringToNum(iText,&lastValue);
- if (lastValue!=gServiced) {
- NumToString(gServiced,iText);
- SetIText(iHndl,iText);
- }
-
- GetDItem(gMainDialog,kFreeItem,&iType,&iHndl,&iRect);
- GetIText(iHndl,iText);
- StringToNum(iText,&lastValue);
- if (lastValue!=gFree) {
- NumToString(gFree,iText);
- SetIText(iHndl,iText);
- }
-
- GetDItem(gMainDialog,kRunningItem,&iType,&iHndl,&iRect);
- GetIText(iHndl,iText);
- StringToNum(iText,&lastValue);
- if (lastValue!=gRunning) {
- NumToString(gRunning,iText);
- SetIText(iHndl,iText);
- }
-
- GetDItem(gMainDialog,kCompletedItem,&iType,&iHndl,&iRect);
- GetIText(iHndl,iText);
- StringToNum(iText,&lastValue);
- if (lastValue!=gCompleted) {
- NumToString(gCompleted,iText);
- SetIText(iHndl,iText);
- }
-
- GetDItem(gMainDialog,kGreetingItem,&iType,&iHndl,&iRect);
- GetIText(iHndl,gGreetingData);
- }
-
-
- /* handles events important to our dialog
- */
-
- Boolean HandleDialogEvents(EventRecord *ev)
- {
- DialogPtr theDlg;
- short item;
-
- if (!IsDialogEvent(ev))
- return false;
-
- if (DialogSelect(ev,&theDlg,&item)) {
- if (item==kQuitItem)
- gDone = true;
- }
-
- return true;
- }
-
-
- /* handles mouse down events. we only do dragging, and nothing else
- */
-
- void HandleMouseDown(Point mouseHit)
- {
- WindowPtr window;
- Rect limit;
-
- SetRect(&limit,-32000,-32000,32000,32000);
-
- switch (FindWindow(mouseHit,&window)) {
- case inDrag:
- DragWindow(window,mouseHit,&limit);
- case inGoAway:
- if (TrackGoAway(window,mouseHit))
- gDone = true;
- }
- }
-